<?php

namespace common\models\school;

use Yii;

/**
 * This is the model class for table "{{%classroom}}".
 *
 * @property int $id
 * @property string $number 教室编号
 * @property string $name 教室名称
 * @property string $school_id 学校ID
 * @property string $description 教室描述
 * @property int $status 状态
 * @property string $created_at 创建时间
 * @property string $updated_at 更新时间
 */
class Classroom extends \common\base\ActiveRecord {

    use \common\traits\Constants;
    use \common\traits\TimestampBehavior;

    const STATUS_ACTIVE = 10;
    const STATUS_DEFAULT = 0;

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%classroom}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['number', 'name'], 'required'],
            [['school_id', 'status', 'created_at', 'updated_at'], 'integer'],
            [['number'], 'string', 'max' => 32],
            [['name'], 'string', 'max' => 50],
            [['description'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'number' => '教室编号',
            'name' => '教室名称',
            'school_id' => '学校ID',
            'description' => '教室描述',
            'status' => '状态',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }

    public function getSchool() {
        return $this->hasOne(School::className(), ['id' => 'school_id']);
    }

}
